/****************************************Copyright (c)**************************************************
**                                         2016-03
**
**                                
**
**
**--------------File Info-------------------------------------------------------------------------------
** File name:		    ht6x1x_misc.c
** Last modified Date:  2016-03-29
** Last Version:		v1.0
** Descriptions:		
**
**------------------------------------------------------------------------------------------------------
** Created by:			Evan Chen
** Created date:		2016-03-29
** Version:				v1.0
** Descriptions:		
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "ht6x1x_misc.h"

void MISC_GotoSleepMode(void)
{
	SCB->SCR = 0x0004;
	
	while(1) 
	{
		__WFI();
		__NOP();
	}
}

void MISC_GotoHoldMode(void)
{
	SCB->SCR = 0x0000;
	
	while(1) 
	{
		__WFI();
		__NOP();
	}
}

void MISC_Enable_Interrupt(void)
{
	__enable_irq();
}

void MISC_Disable_Interrupt(void)
{
	__disable_irq();
}

void MISC_SystemReset(void)
{
	NVIC_SystemReset();
	while(1) ;
}

uint32_t MISC_WakeupState(MISC_Wakeup_TypeDef type)
{
	return (uint32_t)(HT_PMU->WAKEIF & type);
}

void MISC_EnableIRQs(uint32_t irqs)
{
	NVIC->ISER[0] = irqs;	
}

void MISC_DisableIRQs(uint32_t irqs)
{
	NVIC->ICER[0] = irqs;	
}
	
